<template>
  <div class="page-container">
    <el-form
      ref="submitForm"
      :model="formData"
      :rules="rules"
      :inline="true"
      class="custom-form">
      <el-row>
        <el-col :md="12" :sm="24">
          <el-form-item label="下拉选择：" prop="value1">
            <SelectList v-model="formData.value1" :is-has-dict="false" :default-option="value1List" />
          </el-form-item>
        </el-col>
        <el-col :md="12" :sm="24">
          <el-form-item label="弹窗选择：" prop="value2">
            <SelectDialog v-model="formData.value2" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :md="12" :sm="24">
          <el-form-item label="日期选择器：" prop="value3">
            <DatePicker v-model="formData.value3" />
          </el-form-item>
        </el-col>
        <el-col :md="12" :sm="24">
          <el-form-item label="日期时间选择器：" prop="value4">
            <DateTimePicker v-model="formData.value4" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" justify="center">
        <el-col>
          <el-form-item>
            <el-button type="primary" @click="submitForm()">提交</el-button>
            <el-button @click="resetForm()">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import SelectList from '@/views/samples/comExample/sample-form/components/SelectList.vue';
import SelectDialog from '@/views/samples/comExample/sample-form/components/SelectDialog.vue';
import DatePicker from '@/views/samples/comExample/sample-form/components/DatePicker.vue';
import DateTimePicker from '@/views/samples/comExample/sample-form/components/DateTimePicker.vue';

export default {
  name: 'SampleForm', // 表单项示例
  components: {
    SelectList,
    SelectDialog,
    DatePicker,
    DateTimePicker
  },
  data() {
    return {
      formData: {
        value1: '',
        value2: '',
        value3: [],
        value4: [],
      },
      rules: {
        value1: { required: true, message: '请选择', trigger: ['blur', 'change'] },
        value2: { required: true, message: '请选择', trigger: ['blur', 'change'] },
        value3: { required: true, message: '请选择', trigger: ['blur', 'change'] },
        value4: { required: true, message: '请选择', trigger: ['blur', 'change'] },
      },
      value1List: [
        { label: '选项一', value: '1' },
        { label: '选项二', value: '2' },
        { label: '选项三', value: '3' },
      ]
    };
  },
  methods: {
    submitForm() {
      console.log(this.formData, 'submit!');
      // this.$refs.submitForm.validate((valid) => {
      //   if (valid) {
      //     console.log(this.formData, 'submit!')
      //   }
      // })
    },
    resetForm(formName) {
      this.$refs.submitForm.resetFields();
    },
  }
};
</script>

<style scoped lang="scss">
</style>
